﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Diagnostics;
using System.Reflection;
using System.ServiceModel;

using WcfCore;

namespace WcfSvcHost
{
	class Program
	{
		static void Main(string[] args)
		{
			Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;

			if (args.Length != 1)
			{
				Console.WriteLine("Gotta specify the input file.");
				throw new ArgumentException("Wrong command line arguments.");
			}

			string filename = args[0];
			if (!File.Exists(filename))
			{
				Console.WriteLine("Gotta specify an existing file containing the test input information.");
				throw new ArgumentException("Wrong command line arguments.");
			}

			FileInfo fi = new FileInfo(filename);
			WcfTestInput input = WcfTestInput.Deserialize(fi.FullName);

			Console.WriteLine("ServiceClassName: {0} ({1})", input.ServiceType.Name, input.Binding.ToString());
			WcfServiceHostFactory.CreateHost(input);

			Console.WriteLine("The service host is ready.");
			Console.WriteLine("Press <ENTER> to terminate service runner.");
			Console.ReadLine();
		}
	}
}
